# ~*~ coding: utf-8 ~*~
import time


from apps.ops.celery.decorator import after_app_ready_start
from apps.extensions import celery, db
from apps.terminal.models import Session


@celery.task
@after_app_ready_start
def process_terminate_session():
    params = {
        'date_end': time.time(),
        'is_finished': 1,
    }
    db.session.query(Session).filter(Session.is_finished == 0).update(params, synchronize_session=False)
    db.session.commit()
